<TITLE>BGI Documentation for 
line
</TITLE>
<H2>
line
</H2>
<HR>
<DL>


<DT><B>Syntax</B><DD>
<PRE>
#include &lt;graphics.h&gt;
void line(int x1, int y1, int x2, int y2);
</PRE>



<DT><B>Description</B><DD>
line draws a line in the current color, using the current line style and thickness between the two points specified, (x1,y1) and (x2,y2), without updating the current position (CP).


<P><DT><B>Return Value</B><DD>
None.


<P><DT><B>See also</B>
<DD><A HREF="getlinesettings.html"> getlinesettings </A>
<DD><A HREF="linerel.html"> linerel </A>
<DD><A HREF="lineto.html"> lineto </A>
<DD><A HREF="setcolor.html"> setcolor </A>
<DD><A HREF="setlinestyle.html"> setlinestyle </A>
<DD><A HREF="setwritemode.html"> setwritemode </A>


<P><DT><B>Example</B><DD>
<PRE>
/* line example */ 

#include &lt;graphics.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;conio.h&gt;

int main(void)
{

   /* request autodetection */
   int gdriver = DETECT, gmode, errorcode;
   int xmax, ymax;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();

   if (errorcode != grOk) { /* an error occurred */
      printf("Graphics error: %s\n", grapherrormsg(errorcode));

      printf("Press any key to halt:");
      getch();
      exit(1);
   }

   setcolor(getmaxcolor());
   xmax = getmaxx();
   ymax = getmaxy();

   /* draw a diagonal line */
   line(0, 0, xmax, ymax);

   /* clean up */
   getch();
   closegraph();
   return 0;
}
</PRE>


</DL>
<HR>
<A HREF="index.html">Back to index</A>
